<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图浮动</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
     .box1{
        position: relative;
         margin: 150px auto;
         background-image: url(images/pan.jpg);
         background-size: 300px 300px;
         width: 300px;
         height: 300px;
         border-radius: 8px;
        }
        .box2{
            width: 300px;
            height: 300px;
            font-size: 25px;
            text-align: center;
            color: wheat;
            background-color: rgba(17,19,17, 0.6);
            transition: all 0.2s ease 0s;
            border-radius: 8px;
         opacity: 0;

        
        }
   
        .p1{
            transition: all 0.5s ease 0s;
            position: absolute;
            top: 0;
            left: 100px;
        }
        .p2{
            transition: all 0.5s ease 0s;
            position: absolute;
            left: 90px;
            bottom: 0;
        }
  
        .box1:hover .box2{
            opacity: 1;
        }
        .box1:hover .p1{
     
           transform: translateY(110px);
            
        }
        .box1:hover .p2{
     
           transform: translateY(-110px);
            
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2">
            <p class="p1">宇宙无敌</p> 

            <p class="p2">超级大帅哥</p>

        </div>
    </div>
  
</body>
</html>